Add support for setting and getting domain maxmem.
DOMFLAGS_SHUTDOWNMASK;
info->nr_pages = op.u.getdomaininfo.tot_pages;
- info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT-10);
+ info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT);
info->shared_info_frame = op.u.getdomaininfo.shared_info_frame;
info->cpu_time = op.u.getdomaininfo.cpu_time;
strncpy(info->name, op.u.getdomaininfo.name, XC_DOMINFO_MAXNAME);
XcObject *xc = (XcObject *)self;
u32 dom;
- unsigned long max_memkb;
+ unsigned long maxmem_kb;
- static char *kwd_list[] = { "dom", "max_memkb", NULL };
+ static char *kwd_list[] = { "dom", "maxmem_kb", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
- &dom, &max_memkb) )
+ &dom, &maxmem_kb) )
return NULL;
- if ( xc_domain_setmaxmem(xc->xc_handle, dom, max_memkb) != 0 )
+ if ( xc_domain_setmaxmem(xc->xc_handle, dom, maxmem_kb) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
" blocked [int]: Bool - is the domain blocked waiting for an event?\n"
" running [int]: Bool - is the domain currently running?\n"
" mem_kb [int]: Memory reservation, in kilobytes\n"
+ " maxmem_kb [int]: Maximum memory limit, in kilobytes\n"
" cpu_time [long]: CPU time consumed, in nanoseconds\n"
" name [str]: Identifying name\n"
" shutdown_reason [int]: Numeric code from guest OS, explaining "
METH_VARARGS | METH_KEYWORDS, "\n"
"Set a domain's memory limit\n"
" dom [int]: Identifier of domain.\n"
- " max_memkb [long]: .\n"
+ " maxmem_kb [long]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ NULL, NULL, 0, NULL }
'latency' : latency,
'xtratime': xtratime })
+ def xend_domain_maxmem_set(self, id, memory):
+ return self.xendPost(self.domainurl(id),
+ { 'op' : 'maxmem_set',
+ 'memory' : memory })
+
def xend_domain_vifs(self, id):
return self.xendGet(self.domainurl(id),
{ 'op' : 'vifs' })
{'op' : 'inject',
'event' : fileof(sxpr) })
- def xend_dmesg(self):
- return self.xendGet(self.dmesgurl())
-
def xendmain(srv, asynch, fn, args):
if asynch:
client = AsynchXendClientProtocol()
dom = int(dom)
return xc.shadow_control(dom, op)
+ def domain_maxmem_set(self, dom, mem):
+ """Set the memory limit for a domain.
+
+ @param dom: domain
+ @param mem: memory limit (in MB)
+ @return: 0 on success, -1 on error
+ """
+ dom = int(dom)
+ maxmem = int(mem) * 1024
+ return xc.domain_setmaxmem(dom, maxmem_kb = maxmem)
+
def instance():
"""Singleton constructor. Use this instead of the class constructor.
['memory', self.memory] ]
if self.info:
- run = (self.info['running'] and 'r') or '-'
- block = (self.info['blocked'] and 'b') or '-'
- stop = (self.info['paused'] and 'p') or '-'
- susp = (self.info['shutdown'] and 's') or '-'
- crash = (self.info['crashed'] and 'c') or '-'
- state = run + block + stop + susp + crash
+ sxpr.append(['maxmem', self.info['maxmem_kb']/1024 ])
+ run = (self.info['running'] and 'r') or '-'
+ block = (self.info['blocked'] and 'b') or '-'
+ pause = (self.info['paused'] and 'p') or '-'
+ shut = (self.info['shutdown'] and 's') or '-'
+ crash = (self.info['crashed'] and 'c') or '-'
+ state = run + block + pause + shut + crash
sxpr.append(['state', state])
if self.info['shutdown']:
reason = shutdown_reason(self.info['shutdown_reason'])
val = fn(req.args, {'dom': self.dom.id})
return val
+ def op_maxmem_set(self, op, req):
+ fn = FormFn(self.xd.domain_maxmem_set,
+ [['dom', 'int'],
+ ['memory', 'int']])
+ val = fn(req.args, {'dom': self.dom.id})
+ return val
+
def op_vifs(self, op, req):
return self.xd.domain_vif_ls(self.dom.id)
xm.prog(ProgPincpu)
+class ProgMaxmem(Prog):
+ group = 'domain'
+ name = 'maxmem'
+ info = """Set domain memory limit."""
+
+ def help(self, args):
+ print args[0], "DOM MEMORY"
+ print "\nSet the memory limit for domain DOM to MEMORY megabytes."
+
+ def main(self, args):
+ if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
+ v = map(int, args[1:3])
+ server.xend_domain_maxmem_set(*v)
+
+xm.prog(ProgMaxmem)
+
class ProgBvt(Prog):
group = 'scheduler'
name = "bvt"
info = """Print Xen boot output."""
def main(self, args):
- print server.xend_dmesg()[1]
+ print server.xend_node_dmesg()[1]
xm.prog(ProgDmesg)